/*
               File: C25
        Description: Conversion for table MMMRC10
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 12:53:59.99
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c25 extends GXProcedure
{
   public c25( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c25.class ), "" );
   }

   public c25( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C252 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A364MarUUM = C252_A364MarUUM[0] ;
         A363MarHUM = C252_A363MarHUM[0] ;
         A362MarFUM = C252_A362MarFUM[0] ;
         A361MarUCR = C252_A361MarUCR[0] ;
         A360MarHCR = C252_A360MarHCR[0] ;
         A359MarFCR = C252_A359MarFCR[0] ;
         A190MarEst = C252_A190MarEst[0] ;
         A358MarTip = C252_A358MarTip[0] ;
         A357MarNom = C252_A357MarNom[0] ;
         A189MarCod = C252_A189MarCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0025

         */
         AV2MarCod = GXutil.str( A189MarCod, 5, 0) ;
         if ( C252_n357MarNom[0] )
         {
            AV3MarNom = "" ;
         }
         else
         {
            AV3MarNom = A357MarNom ;
         }
         if ( C252_n358MarTip[0] )
         {
            AV4MarTip = "" ;
         }
         else
         {
            AV4MarTip = A358MarTip ;
         }
         if ( C252_n190MarEst[0] )
         {
            AV5MarEst = "" ;
         }
         else
         {
            AV5MarEst = A190MarEst ;
         }
         if ( C252_n359MarFCR[0] )
         {
            AV6MarFCR = GXutil.nullDate() ;
         }
         else
         {
            AV6MarFCR = A359MarFCR ;
         }
         if ( C252_n360MarHCR[0] )
         {
            AV7MarHCR = "" ;
         }
         else
         {
            AV7MarHCR = A360MarHCR ;
         }
         if ( C252_n361MarUCR[0] )
         {
            AV8MarUCR = "" ;
         }
         else
         {
            AV8MarUCR = A361MarUCR ;
         }
         if ( C252_n362MarFUM[0] )
         {
            AV9MarFUM = GXutil.nullDate() ;
         }
         else
         {
            AV9MarFUM = A362MarFUM ;
         }
         if ( C252_n363MarHUM[0] )
         {
            AV10MarHUM = "" ;
         }
         else
         {
            AV10MarHUM = A363MarHUM ;
         }
         if ( C252_n364MarUUM[0] )
         {
            AV11MarUUM = "" ;
         }
         else
         {
            AV11MarUUM = A364MarUUM ;
         }
         /* Using cursor C253 */
         pr_default.execute(1, new Object[] {AV2MarCod, AV3MarNom, AV4MarTip, AV5MarEst, AV6MarFCR, AV7MarHCR, AV8MarUCR, AV9MarFUM, AV10MarHUM, AV11MarUUM});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C252_A364MarUUM = new String[] {""} ;
      C252_A363MarHUM = new String[] {""} ;
      C252_A362MarFUM = new java.util.Date[] {GXutil.nullDate()} ;
      C252_A361MarUCR = new String[] {""} ;
      C252_A360MarHCR = new String[] {""} ;
      C252_A359MarFCR = new java.util.Date[] {GXutil.nullDate()} ;
      C252_A190MarEst = new String[] {""} ;
      C252_A358MarTip = new String[] {""} ;
      C252_A357MarNom = new String[] {""} ;
      C252_A189MarCod = new int[1] ;
      A364MarUUM = "" ;
      A363MarHUM = "" ;
      A362MarFUM = GXutil.nullDate() ;
      A361MarUCR = "" ;
      A360MarHCR = "" ;
      A359MarFCR = GXutil.nullDate() ;
      A190MarEst = "" ;
      A358MarTip = "" ;
      A357MarNom = "" ;
      A189MarCod = 0 ;
      GIGXA0025 = 0 ;
      AV2MarCod = "" ;
      C252_n357MarNom = new boolean[] {false} ;
      AV3MarNom = "" ;
      C252_n358MarTip = new boolean[] {false} ;
      AV4MarTip = "" ;
      C252_n190MarEst = new boolean[] {false} ;
      AV5MarEst = "" ;
      C252_n359MarFCR = new boolean[] {false} ;
      AV6MarFCR = GXutil.nullDate() ;
      C252_n360MarHCR = new boolean[] {false} ;
      AV7MarHCR = "" ;
      C252_n361MarUCR = new boolean[] {false} ;
      AV8MarUCR = "" ;
      C252_n362MarFUM = new boolean[] {false} ;
      AV9MarFUM = GXutil.nullDate() ;
      C252_n363MarHUM = new boolean[] {false} ;
      AV10MarHUM = "" ;
      C252_n364MarUUM = new boolean[] {false} ;
      AV11MarUUM = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c25__default(),
         new Object[] {
             new Object[] {
            C252_A364MarUUM, C252_n364MarUUM, C252_A363MarHUM, C252_n363MarHUM, C252_A362MarFUM, C252_n362MarFUM, C252_A361MarUCR, C252_n361MarUCR, C252_A360MarHCR, C252_n360MarHCR,
            C252_A359MarFCR, C252_n359MarFCR, C252_A190MarEst, C252_n190MarEst, C252_A358MarTip, C252_n358MarTip, C252_A357MarNom, C252_n357MarNom, C252_A189MarCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short Gx_err ;
   private int A189MarCod ;
   private int GIGXA0025 ;
   private String A364MarUUM ;
   private String A363MarHUM ;
   private String A361MarUCR ;
   private String A360MarHCR ;
   private String A190MarEst ;
   private String A358MarTip ;
   private String A357MarNom ;
   private String AV2MarCod ;
   private String AV3MarNom ;
   private String AV4MarTip ;
   private String AV5MarEst ;
   private String AV7MarHCR ;
   private String AV8MarUCR ;
   private String AV10MarHUM ;
   private String AV11MarUUM ;
   private String Gx_emsg ;
   private java.util.Date A362MarFUM ;
   private java.util.Date A359MarFCR ;
   private java.util.Date AV6MarFCR ;
   private java.util.Date AV9MarFUM ;
   private IDataStoreProvider pr_default ;
   private String[] C252_A364MarUUM ;
   private String[] C252_A363MarHUM ;
   private java.util.Date[] C252_A362MarFUM ;
   private String[] C252_A361MarUCR ;
   private String[] C252_A360MarHCR ;
   private java.util.Date[] C252_A359MarFCR ;
   private String[] C252_A190MarEst ;
   private String[] C252_A358MarTip ;
   private String[] C252_A357MarNom ;
   private int[] C252_A189MarCod ;
   private boolean[] C252_n357MarNom ;
   private boolean[] C252_n358MarTip ;
   private boolean[] C252_n190MarEst ;
   private boolean[] C252_n359MarFCR ;
   private boolean[] C252_n360MarHCR ;
   private boolean[] C252_n361MarUCR ;
   private boolean[] C252_n362MarFUM ;
   private boolean[] C252_n363MarHUM ;
   private boolean[] C252_n364MarUUM ;
}

final class c25__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C252", "SELECT [MarUUM], [MarHUM], [MarFUM], [MarUCR], [MarHCR], [MarFCR], [MarEst], [MarTip], [MarNom], [MarCod] FROM [MMMRC10] WITH (NOLOCK) ORDER BY [MarCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C253", "INSERT INTO [GXA0025] ([MarCod], [MarNom], [MarTip], [MarEst], [MarFCR], [MarHCR], [MarUCR], [MarFUM], [MarHUM], [MarUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 8) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(3) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 10) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 8) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[10])[0] = rslt.getGXDate(6) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 1) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((String[]) buf[14])[0] = rslt.getString(8, 1) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((String[]) buf[16])[0] = rslt.getString(9, 20) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((int[]) buf[18])[0] = rslt.getInt(10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 20);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setString(4, (String)parms[3], 1);
               stmt.setDate(5, (java.util.Date)parms[4]);
               stmt.setString(6, (String)parms[5], 8);
               stmt.setString(7, (String)parms[6], 10);
               stmt.setDate(8, (java.util.Date)parms[7]);
               stmt.setString(9, (String)parms[8], 8);
               stmt.setString(10, (String)parms[9], 10);
               break;
      }
   }

}

